home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / ssetup26.zip / SETUP.CP_ / SETUP.CPP
Text File  |  1995-07-27  |  72KB  |  1,538 lines

  1. // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2. //
  3. //                SETUP.CPP
  4. //                Main file for "MAIN.EXE" Setup Studio sample program
  5. //                Use with CSETUP.DLL release 2.6.
  6. //
  7. // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  8. //
  9. //                This file requires Microsoft Visual C++ 1.5x Compiler and MFC 2.5x class Library.
  10. //                Warning: You use this product at your own risk! You are responsible for making suitable backups in case it screws up. 
  11. //                You can use this file as a template and you can redistribute programs (without any royalties) but 
  12. //                you must not dsitribute this source code with your personnal passwords.
  13. //
  14. // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  15. //
  16. //                With the UNREGISTERED version you can' t install icons or runs programs at the end of the Set-up
  17. //                because your files will be in the TEST directory (and not in the user' s directory).
  18. //
  19. // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  20. //
  21. //                There are 5 classes in this file:
  22. //
  23. //                        CSetupApp:        The application management 
  24. //                        CFirst:                  A splash dialog box with initialisation management
  25. //                        CMain:                The main application window which calls dialog boxes and GoSetup function
  26. //                        CChoice1:          To choose path and language
  27. //                        CChoice2:          To choose files to install
  28. //
  29. // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  30. //                Remark:
  31. //              nPanelBold... specify italic mode ( not the bold mode ! )
  32. // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  33.  
  34.  
  35.  
  36.             // ----------------------------------------------------------
  37.             //  Private messages
  38.             // ----------------------------------------------------------
  39.             #define PM_FIRST        WM_USER + 0x049                // Message for CFirst Box to start the SetupInitialize
  40.             #define PM_FIRST2        WM_USER + 0x050                // Message for CFirst Box to start the SetupInitialize
  41.             #define IDCHANGEPATH    36                                    // EndDialog value when user want to change the path on Choice2 box
  42.             
  43.             
  44.             // ----------------------------------------------------------
  45.             //  Include files
  46.             // ----------------------------------------------------------
  47.             #include <afx.h>
  48.             #include <afxext.h>
  49.             #include <stdlib.h>
  50.             #include <direct.h>
  51.             #include "setup.h"
  52.             #pragma message ("SETUP.CPP(47): Please put CTL3D.H and CSETUP.H in your INCLUDE directory...")
  53.             #pragma message ("SETUP.CPP(48): And put CTL3D.LIB and CSETUP.LIB in your LIB directory...")
  54.             #include <csetup.h>
  55.             #include <ctl3d.h>
  56.             
  57.             // ----------------------------------------------------------
  58.             //  Local functions
  59.             // ----------------------------------------------------------
  60.                 
  61.             
  62.             
  63.             #ifdef _DEBUG
  64.             #undef THIS_FILE
  65.             static char BASED_CODE THIS_FILE[] = __FILE__;
  66.             #endif
  67.             
  68.             // ----------------------------------------------------------
  69.             //  Local variables
  70.             // ----------------------------------------------------------
  71.                 BOOL bIsSetupOK, bWin4;                        // Result of SetupInitialize Function
  72.                 int iLanguage;                               // Language ( french or English )
  73.                 CString UserPath;                            // Destination path
  74.                 int iType;                                         // User configuration = TYPE_VB, TYPE_TCW, TYPE_MFC or TYPE_NONE
  75.                 long UserConfigSize;                            // The size of the user' s selection
  76.                 static char szOriginalPath[_MAX_PATH];             // First command line argument
  77.                 static char szTempSetupPath[_MAX_PATH];        // Second command line argument
  78.             
  79.             // ----------------------------------------------------------
  80.             //  Local constants
  81.             // ----------------------------------------------------------
  82.                 #define TYPE_VB                0              // Indicate Best path for VB users
  83.                 #define TYPE_TCW          1                // Indicate Best path for TCW users
  84.                 #define TYPE_MFC          2                // Indicate Best path for MFC users
  85.                 #define TYPE_NONE          3                // Normal path must be used
  86.             
  87.  
  88.  
  89.  
  90.  
  91. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  92. //                                                                         I try to make a generic Setup Application...                                                                                              ///
  93. //                                                           This program can have up to 15 checkboxes and each checkbox is                                                                  ///
  94. ///                                                                associated with a section. This program performs basic operations                                                                 //
  95. //                                                                like section management, icons installation, winfile association                                                                      //
  96. //                                                                                and can run an EXE or an HLP file.                                                                                                    //
  97. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  98.         
  99.         
  100.         // ----------------------- General settings ------------------------------------
  101.         const CString     szYourName                 = "TEST";                              // Put your <szYourName> password here, or TEST if you are not registered
  102.         const CString    szYourPassword           = "";               // Put your <szPassword> here or nothing if you are not registered
  103.         const int             iBackgroundPaper     = BROSSE_3DCIRCLE;     // Choose the brush to use as the background paper, ( BROSSE_* )
  104.         const BOOL      bBeepMode                = TRUE;                               // True if you want the BEEP mode, FALSE if not
  105.         const BOOL        bVerifyMode                 = TRUE;                            // True if you want the VERIFY mode, FALSE if not
  106.         const CString    szProductName           = "Setup Studio";             // Name of your works
  107.         const CString   szSetupBoxTitle         = "Setup Studio 2.5 - Installation";    // Title of the Copy Dialog Box
  108.         
  109.         // ----------------------- General interface settings ------------------------------------
  110.         const CString        Dialog1Title            = "Setup Studio 2.6";        // Dialog box title for the path and other dialog boxes
  111.         const CString        Dialog3Title            = "Setup Studio - Installation options";        // Dialog box title for the option dialog box
  112.         const CString        Dialog2Title            = "Setup Studio 2.6";        // Dialog box title for the copy dialog box
  113.         
  114.         // ----------------------- Interface settings [PANEL1] ( first panel )------------------------------------
  115.         const int                iPanel1Bitmap             = 0;                                    // Bitmap ID for Panel 1 or 0 to disable it
  116.         const CString        szPanel1Title               = "Setup Studio 2.6";        // Panel 1 title or a blank string to disable it
  117.         const CString        szPanel1TitleFont          = "Arial";                            // Panel 1 title font to use
  118.         const int                 iPanel1TitleSize          = 56;                                   // Panel 1 title font size to use
  119.         const COLORREF lPanel1TitleColor       = RGB(192,192,192);               // Panel 1 title color to use
  120.         const BOOL            bPanel1Title3D            = TRUE;                                // Panel 1 title 3D or not
  121.         const BOOL            bPanel1TitleBold       = TRUE;                               // Panel 1 title bold or not
  122.         const CString        szPanel1Detail               = "The ultimate setup toolkit to\nbuild setup programs for Win16/Win32!";       // Panel 1 detail or a blank string to disable it
  123.         const CString        szPanel1DetailFont          = "Times New Roman";                            // Panel 1 detail font to use
  124.         const int                 iPanel1DetailSize          = 28;                                   // Panel 1 detail font size to use
  125.         const COLORREF lPanel1DetailColor       = RGB(0,0,138);               // Panel 1 detail color to use
  126.         const BOOL            bPanel1Detail3D            = TRUE;                                // Panel 1 detail 3D or not
  127.         const BOOL            bPanel1DetailBold       = TRUE;                               // Panel 1 detail bold or not
  128.         
  129.         // ----------------------- Interface settings [PANEL2] ( user selects files to install )------------------------------------
  130.         const int                iPanel2Bitmap             = 0;                                    // Bitmap ID for Panel 2 or 0 to disable it
  131.         const CString        szPanel2Title               = "Setup Studio 2.6";        // Panel 2 title or a blank string to disable it
  132.         const CString        szPanel2TitleFont          = "Arial";                            // Panel 2 title font to use
  133.         const int                 iPanel2TitleSize          = 56;                                   // Panel 2 title font size to use
  134.         const COLORREF lPanel2TitleColor       = RGB(192,192,192);               // Panel 2 title color to use
  135.         const BOOL            bPanel2Title3D            = TRUE;                                // Panel 2 title 3D or not
  136.         const BOOL            bPanel2TitleBold       = TRUE;                               // Panel 2 title bold or not
  137.         const CString        szPanel2Detail               = "The ultimate setup toolkit to\nbuild setup programs for Win16/Win32!";       // Panel 2 detail or a blank string to disable it
  138.         const CString        szPanel2DetailFont          = "Times New Roman";                            // Panel 2 detail font to use
  139.         const int                 iPanel2DetailSize          = 28;                                   // Panel 2 detail font size to use
  140.         const COLORREF lPanel2DetailColor       = RGB( 0,0,138);               // Panel 2 detail color to use
  141.         const BOOL            bPanel2Detail3D            = TRUE;                                // Panel 2 detail 3D or not
  142.         const BOOL            bPanel2DetailBold       = TRUE;                               // Panel 2 detail bold or not
  143.             
  144.         // ----------------------- Interface settings [PANEL3] ( files transfert )------------------------------------
  145.         const int                iPanel3Bitmap             = 0;                                    // Bitmap ID for Panel 3 or 0 to disable it
  146.         const CString        szPanel3Title               = "Setup Studio 2.6";        // Panel 3 title or a blank string to disable it
  147.         const CString        szPanel3TitleFont          = "Arial";                            // Panel 3 title font to use
  148.         const int                 iPanel3TitleSize          = 56;                                   // Panel 3 title font size to use
  149.         const COLORREF lPanel3TitleColor       = RGB(192,192,192);               // Panel 3 title color to use
  150.         const BOOL            bPanel3Title3D            = TRUE;                                // Panel 3 title 3D or not
  151.         const BOOL            bPanel3TitleBold       = TRUE;                               // Panel 3 title bold or not
  152.         const CString        szPanel3Detail               = "[] Built-in Zip\\Unzip engine,\n[] No need to learn another language,\n[] No more than 4 functions required,\
  153. \n[] Up to 1100 files, 30 disquettes...,\n[] Files dates checking, auto. backups...,\n[] Shared files support,\n[] 2 customizable languages,\n[] VB and VC templates,\
  154. \n[] WRI manual and HLP help file,\n[] MS Setup Toolkit and Win95 compatible,\n[] And lots more...";       // Panel 3 detail or a blank string to disable it
  155.         const CString        szPanel3DetailFont          = "Arial";                            // Panel 3 detail font to use
  156.         const int                 iPanel3DetailSize          = 22;                                   // Panel 3 detail font size to use
  157.         const COLORREF lPanel3DetailColor       = RGB(0,0,138);               // Panel 3 detail color to use
  158.         const BOOL            bPanel3Detail3D            = TRUE;                                // Panel 3 detail 3D or not
  159.         const BOOL            bPanel3DetailBold       = FALSE;                               // Panel 3 detail bold or not
  160.         
  161.         // ----------------------- Shared files settings ------------------------------------
  162.         const BOOL         bUseSharedBatch     = FALSE;                // Set this to TRUE if you wish to use the shared batch mode
  163.         const CString     szBatchFile                = "";                           // Dir and Name for the batch file, default = SYSSETUP.TMP\\SYSSETUP.BAT
  164.         const CString     szBatchDir                   = "";                       //  Temporary dir for shared files, default = SYSSETUP.TMP with final slash
  165.         
  166.         // ----------------------- LOG file settings ------------------------------------
  167.         const BOOL        bUseLogFile                = TRUE;                     // TRUE if you wish to use a LOG file, FALSE if not.
  168.         const CString    szLogFileName          = "SETUP.LOG";    //  Log file name ( without dir specification )
  169.         
  170.         // ----------------------- SECTIONS management ------------------------------------                                            
  171.         //    1 Section is associated to 1 checkbox
  172.         typedef struct sSectionEntry{
  173.             unsigned        bSelected : 1;                                        // ---> TRUE if the user selects this section, FALSE if not
  174.             long                lSize;                                                    // ---> Section Size ( in bytes )
  175.             CString              Name;                                                    // ---> Section name ( from SETUP.INF )
  176.             CString              Directory;                                            // ---> Destination relative directory for the section ( DIRX\\ for example )
  177.             CString              ELabel;                                                // ---> English label for the section ( will be associated with a CHECKBOX )
  178.             CString              FLabel;                                                 // ---> French Label for the section ( will be associated with a CHECKBOX )
  179.             }SSECTIONENTRY;              
  180.         
  181.         const int NumberOfSections = 4;                                      // From 1 to 8 sections ( and checkboxes )    
  182.         SSECTIONENTRY Section[ NumberOfSections];
  183.         
  184.         //     Now it' s depend of your INF File: You must create section entries for all checkboxes you want and 
  185.         //    you must respect the diskettes order if your setup program contains more than 1 diskette:
  186.         //    See InitInstance for Implementation
  187.         
  188.         // ----------------------- Icons management ------------------------------------                                            
  189.         const BOOL        bInstallIcons = TRUE;                        // Install icons if section 0 is selected
  190.         typedef struct sIconEntry 
  191.             {
  192.             CString        szIconRelativeName;                             // Program name for specified icon  ( CTL3D\\SSTUDIO.EXE for example )
  193.             CString     EGroupName;                                        // Group Name ( english )
  194.             CString        EIconName;                                          // Icon title ( english )
  195.             CString        EIconText;                                            // Icon description ( english ) --> "" to add this icon without any dialog box
  196.             CString     FGroupName;                                        // Group Name ( french )
  197.             CString        FIconName;                                          // Icon title ( french )
  198.             CString        FIconText;                                            // Icon description ( french )
  199.             }ICONENTRY;
  200.                          
  201.         const int NumberOfIcons     = 6;                              // How many icons
  202.         ICONENTRY far IconEntry[NumberOfIcons];
  203.         //    See InitInstance for Implementation
  204.                         
  205.         // ----------------------- Association management ------------------------------------                                            
  206.         const BOOL bMakeAssociation = TRUE;                    // TRUE if you wish to create or change WinFile associations
  207.         typedef struct sWFAsso
  208.             {
  209.             CString        szProgName;                                        // EXE file name ( with the relative path if any )
  210.             CString        szExt;                                                   // File extension to create ( TXT, DOC ... )
  211.             }SWFASSO;
  212.         
  213.         const int NumberOfAsso = 1;                                      // Set the number of associations to create
  214.         SWFASSO    WFAsso[ NumberOfAsso];
  215.         //    See InitInstance for Implementation
  216.         
  217.         // ----------------------- Last step: we launch something ------------------------------------                                            
  218.         
  219.         //////////////////////////////////////////////////////////////////////////////////////////////
  220.         //    SPECIFIC for this setup:
  221.         //    We can' t run the Wizard, because this program uses CSETUP.DLL.
  222.         //    If you do it, you will get a share vialation error because the Wizard
  223.         //    will load CSETUP.DLL from the temporary setup directory when FINISH.EXE
  224.         //    is deleting this directory...
  225.         //    That' s why we run the HLP file instead!
  226.         //////////////////////////////////////////////////////////////////////////////////////////////
  227.         const CString szLaunch     = "SSTUDIO.HLP";            // Give a HLP or an EXE, COM, PIF, BAT file to launch when the setup is ok
  228.  
  229.  
  230.  
  231.  
  232. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  233. //                                                                                        End of generic declarations.                                                                                                    //
  234. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  235.  
  236.  
  237.  
  238.  
  239. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  240. //                                                                        Implementation - Specific ( so change the following values )                                                                //
  241. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  242.  
  243.             // ----------------------------------------------------------
  244.             //  Constructor
  245.             // ----------------------------------------------------------
  246.             CSetupApp::CSetupApp()
  247.             {       
  248.             //     Now it' s depend of your INF File: You must create section entries for all checkboxes you want and 
  249.             //    you must use the diskettes order if your setup program contains more than 1 diskette:
  250.             
  251.             // -----------------------------------------------------------------------
  252.             //     We define the sections (as we do
  253.             //  with the Setup Studio Wizard)
  254.             // -----------------------------------------------------------------------
  255.             
  256.             Section[0].Name = "Files";            // no directory specification because we use the main destination directory
  257.             Section[0].ELabel = "&Main files.";
  258.             Section[0].FLabel = "&Fichiers principaux.";
  259.             
  260.             Section[1].Name = "MANUAL";
  261.             Section[1].ELabel = "&WRI manual.";
  262.             Section[1].FLabel = "&Mode d' emploi (WRI).";
  263.             
  264.             Section[2].Name = "VBTEMPLATE";
  265.             Section[2].ELabel = "Visual Basic &Template.";
  266.             Section[2].FLabel = "ModΦle pour &Visual Basic.";
  267.             Section[2].Directory = "TEMPLATE\\VB\\";
  268.             
  269.             Section[3].Name = "VCTEMPLATE";
  270.             Section[3].ELabel = "Visual &C++ Template.";
  271.             Section[3].FLabel = "ModΦle pour Visual &C++.";
  272.             Section[3].Directory = "TEMPLATE\\VC\\";
  273.             
  274.             
  275.             // -----------------------------------------------------------------------
  276.             //     Now, we add the icons (they will be installed
  277.             //    if the user installs the first main Section)
  278.             // -----------------------------------------------------------------------
  279.             //    Under Win32 ( NT >= 3.52 or Win4), the dialog
  280.             //    box won' t be displayed.
  281.             // -----------------------------------------------------------------------
  282.             
  283.             IconEntry[0].szIconRelativeName = "SSTUDIO.EXE";    // Icon name ( will be changed into UserPath + Name )
  284.             IconEntry[0].EGroupName = "Setup Studio 2.6";
  285.             IconEntry[0].EIconName = "Setup Wizard";
  286.             IconEntry[0].EIconText = "The Setup Studio Wizard is the useful assistant to layout files.";
  287.             IconEntry[0].FGroupName = "Setup Studio 2.6";
  288.             IconEntry[0].FIconName = "Setup Wizard";
  289.             IconEntry[0].FIconText = "Le Setup Studio Wizard vous permet de crΘer les disquettes pour votre programme.";
  290.             
  291.             IconEntry[1].szIconRelativeName = "SSTUDIO.HLP";    // Icon name ( will be changed into UserPath + Name )
  292.             IconEntry[1].EGroupName = "Setup Studio 2.6";
  293.             IconEntry[1].EIconName = "Help File";
  294.             IconEntry[1].EIconText = "This HLP file lets you read the required informations to build your Setup program.";
  295.             IconEntry[1].FGroupName = "Setup Studio 2.6";
  296.             IconEntry[1].FIconName ="Aide Online";
  297.             IconEntry[1].FIconText = "Ce fichier HLP donne toutes les informations nΘcessaires pour construire le programme d' installation.";
  298.             
  299.             IconEntry[2].szIconRelativeName = "MANUAL.WRI";    // Icon name ( will be changed into UserPath + Name )
  300.             IconEntry[2].EGroupName = "Setup Studio 2.6";
  301.             IconEntry[2].EIconName = "Manual";
  302.             IconEntry[2].EIconText = "Would you like to print this Setup Studio manual?";
  303.             IconEntry[2].FGroupName = "Setup Studio 2.6";
  304.             IconEntry[2].FIconName ="Mode d' emploi";
  305.             IconEntry[2].FIconText = "Pour Θtudier ce mode d' emploi (format WRI), nous vous conseillons de l' imprimer.";
  306.             
  307.             IconEntry[3].szIconRelativeName = "READ.ME";    // Icon name ( will be changed into UserPath + Name )
  308.             IconEntry[3].EGroupName = "Setup Studio 2.6";
  309.             IconEntry[3].EIconName = "READ.ME";
  310.             IconEntry[3].EIconText = "These are basic informations about the Setup Studio toolkit.";
  311.             IconEntry[3].FGroupName = "Setup Studio 2.6";
  312.             IconEntry[3].FIconName ="READ.ME";
  313.             IconEntry[3].FIconText = "Les informations essentielles.";
  314.             
  315.             IconEntry[4].szIconRelativeName = "TEMPLATE\\VB\\MAIN.MAK";    // Icon name ( will be changed into UserPath + Name )
  316.             IconEntry[4].EGroupName = "Setup Studio 2.6";
  317.             IconEntry[4].EIconName = "VB Template";
  318.             IconEntry[4].EIconText = "Visual Basic users may use this VB template with their setup project.";
  319.             IconEntry[4].FGroupName = "Setup Studio 2.6";
  320.             IconEntry[4].FIconName ="ModΦle VB";
  321.             IconEntry[4].FIconText = "Les utilisateurs de Visual Basic peuvent utiliser ce modΦle VB pour leurs projets de setup.";
  322.             
  323.             IconEntry[5].szIconRelativeName = "TEMPLATE\\VC\\MAIN.MAK";    // Icon name ( will be changed into UserPath + Name )
  324.             IconEntry[5].EGroupName = "Setup Studio 2.6";
  325.             IconEntry[5].EIconName = "VC Template";
  326.             IconEntry[5].EIconText = "Visual C++ (1.5x) users may use this VC template with their setup project.";
  327.             IconEntry[5].FGroupName = "Setup Studio 2.6";
  328.             IconEntry[5].FIconName ="ModΦle VC";
  329.             IconEntry[5].FIconText = "Les utilisateurs de Visual C++ (1.5x) peuvent utiliser ce modΦle VC pour leurs projets de setup.";
  330.             
  331.             
  332.             // -----------------------------------------------------------------------
  333.             //     Now we add the WinFile associations
  334.             // -----------------------------------------------------------------------
  335.                    
  336.             WFAsso[0].szProgName = "SSTUDIO.EXE";        // relative program name (using the chosen dest. dir)
  337.             WFAsso[0].szExt = "CFG";        // extension to add
  338.             
  339.             }
  340.         
  341.  
  342.             // ----------------------------------------------------------
  343.             //  WM_INITDIALOG
  344.             //  Guess the best path for user
  345.             // ----------------------------------------------------------
  346.             BOOL CChoice1::OnInitDialog()
  347.                 {
  348.                 /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  349.                 CDialog::OnInitDialog();
  350.                 CString TempVBPath;
  351.                 register int i=0;
  352.                 SetWindowText( Dialog2Title );
  353.                 // We change the font weight
  354.                 if ((hfontDlg = (HFONT) SendMessage(WM_GETFONT) )) 
  355.                     {
  356.                     if (::GetObject(hfontDlg, sizeof(LOGFONT), (LPSTR) &lFont)) 
  357.                         {
  358.                         lFont.lfWeight = FW_NORMAL;
  359.                         if (hfontDlg = CreateFontIndirect((LPLOGFONT) &lFont)) 
  360.                             {
  361.                             SendDlgItemMessage( IDC_EDITSRCPATH, WM_SETFONT, (WPARAM) hfontDlg, 0);
  362.                             SendDlgItemMessage( IDC_GROUPLANGUAGE, WM_SETFONT, (WPARAM) hfontDlg, 0);
  363.                             SendDlgItemMessage( IDC_RADIOENGLISH, WM_SETFONT, (WPARAM) hfontDlg, 0);
  364.                             SendDlgItemMessage( IDC_RADIOFRENCH, WM_SETFONT, (WPARAM) hfontDlg, 0);
  365.                             SendDlgItemMessage( IDC_TEXTE, WM_SETFONT, (WPARAM) hfontDlg, 0);
  366.                             }
  367.                         }
  368.                     }
  369.                 SetClassWord( m_hWnd, GCW_HICON, (WORD)( (AfxGetApp())->LoadIcon( IDR_MAINFRAME )) );
  370.                 Ctl3dSubclassDlg( m_hWnd, CTL3D_ALL );                              
  371.                 CenterDialogBox( m_hWnd );
  372.                 CString ProductName;
  373.                 ProductName = ( iLanguage == LANGUAGE_FRENCH )? "Indiquer le rΘpertoire o∙ vous souhaitez installer ": "Please, give the directory in which you would like to install ";
  374.                 ProductName += szProductName;
  375.                 ProductName += ( iLanguage == LANGUAGE_FRENCH )?" et cliquer sur 'OK':":" and click on 'OK'";
  376.                 CheckRadioButton( IDC_RADIOENGLISH, IDC_RADIOFRENCH, ( iLanguage == LANGUAGE_FRENCH )?IDC_RADIOFRENCH: IDC_RADIOENGLISH );
  377.                 SetDlgItemText( IDC_GROUPLANGUAGE, ( iLanguage == LANGUAGE_FRENCH )? "Votre langage... " : "Setup language... ");
  378.                 SetDlgItemText( IDC_TEXTE, ProductName );
  379.                 SetDlgItemText( IDCANCEL, ( iLanguage == LANGUAGE_FRENCH )?"&Abandonner":"&Abort");
  380.                 if ( UserPath.GetLength() > 0 )
  381.                     SetDlgItemText( IDC_EDITSRCPATH, UserPath );
  382.                 else
  383.                     {
  384.                     /////////////////////////////////////////////////////////// Specific //////////////////////////////////////////////////////////////////////
  385.                     //    We try to guess the best destination directory
  386.                     if ( DoesFileExist( "VB.INI", FALSE) )
  387.                         {
  388.                         GetWinFileAssociation( "FRM", TempVBPath.GetBuffer(_MAX_PATH) ) ;
  389.                         TempVBPath.ReleaseBuffer();
  390.                         if ( TempVBPath.GetLength() > 0 )
  391.                             {
  392.                             TempVBPath =  TempVBPath.Left( TempVBPath.GetLength() - 6 ); // kill VB.EXE
  393.                             TempVBPath += "SSETUP26";    //  dir no slash
  394.                             FormatFileNameValid( TempVBPath, TRUE, UserPath.GetBuffer( _MAX_PATH ) );
  395.                             UserPath.ReleaseBuffer();
  396.                             UserPath.MakeUpper();
  397.                             iType = TYPE_VB;
  398.                             }
  399.                         }
  400.                     if ( DoesFileExist( "TCW.INI", FALSE) )
  401.                         {
  402.                         GetWinFileAssociation( "PRJ", TempVBPath.GetBuffer(_MAX_PATH) ) ;
  403.                         TempVBPath.ReleaseBuffer();
  404.                         if ( TempVBPath.GetLength() > 0 )
  405.                             {
  406.                             TempVBPath =  TempVBPath.Left( TempVBPath.GetLength() - 10 ); // kill BIN\\TCW.EXE
  407.                             TempVBPath += "SSETUP26" ;        //  dir no slash
  408.                             FormatFileNameValid( TempVBPath, TRUE, UserPath.GetBuffer( _MAX_PATH ) );
  409.                             UserPath.ReleaseBuffer();
  410.                             UserPath.MakeUpper();
  411.                             iType = TYPE_TCW;
  412.                             }
  413.                         }
  414.                     if ( DoesFileExist( "MSVC.INI", FALSE) )
  415.                         {
  416.                         GetPrivateProfileString( "Microsoft Visual C++", "Path1", "", TempVBPath.GetBuffer(100), 98, "MSVC.INI");
  417.                         TempVBPath.ReleaseBuffer();
  418.                         if ( TempVBPath.GetLength() > 0 )
  419.                             {
  420.                             TempVBPath =  TempVBPath.Left( TempVBPath.GetLength() - 3 ); // kill BIN
  421.                             TempVBPath += "SSETUP26";    //  dir no slash
  422.                             FormatFileNameValid( TempVBPath, TRUE, UserPath.GetBuffer( _MAX_PATH ) );
  423.                             UserPath.ReleaseBuffer();
  424.                             UserPath.MakeUpper();
  425.                             iType = TYPE_MFC;
  426.                             }
  427.                         }                                        
  428.                     //    End of specific code ----
  429.                     if ( UserPath.GetLength() < 1 )
  430.                         {
  431.                         GetWindowsDirectory( UserPath.GetBuffer(_MAX_PATH), _MAX_PATH );
  432.                         UserPath.ReleaseBuffer();
  433.                         UserPath = UserPath.Left( 3 );
  434.                         UserPath += "SSETUP26\\" ;      //  dir with slash
  435.                         iType = TYPE_NONE;
  436.                         }
  437.                     SetDlgItemText( IDC_EDITSRCPATH, UserPath );
  438.                     
  439.                 /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  440.                 for ( i = 0 ; i <  NumberOfSections ; i++ )
  441.                     {
  442.                     if ( Section[i].Name.GetLength()> 0 )
  443.                         Section[i].lSize = GetSectionSize( Section[i].Name );
  444.                     }  
  445.                 /////////////////////////////////////////////////////////// Specific //////////////////////////////////////////////////////////////////////
  446.                 //     We select the groups depending on the user development system:
  447.                 //    VB users probably don' t wish to install the VC template...
  448.                 
  449.                 Section[0].bSelected = TRUE;                                                    // [Files]
  450.                 Section[1].bSelected = TRUE;                                                    // [MANUAL]
  451.                 Section[2].bSelected = TRUE;                                                    // [VBTEMPLATE]
  452.                 Section[3].bSelected = (iType != TYPE_VB)?TRUE:FALSE;         // [VCTEMPLATE]
  453.                 }    
  454.             (CEdit*)(GetDlgItem( IDC_EDITSRCPATH))->SetFocus(); 
  455.             ((CEdit*)(GetDlgItem( IDC_EDITSRCPATH)))->SetSel( 0, -1L );
  456.             return FALSE;  // return TRUE  unless you set the focus to a control
  457.             }
  458.             
  459.  
  460.             // ----------------------------------------------------------
  461.             //  CMain::PM_FIRST
  462.             //    Main function
  463.             // ----------------------------------------------------------
  464.             afx_msg LRESULT CMain::OnFirstPrivate( WPARAM wParam, LPARAM lParam )
  465.             {
  466.             CChoice1 box1( this );            // path selection
  467.             CChoice2 box2( this );            // options selection
  468.             int test2, iResult;
  469.             register int i = 0;
  470.             CString szLogFile;
  471.             CString SrcHelpFile, DestHelpFile, Message,TempPath, IconPath, WinDir;
  472.             char szTempBatch[_MAX_PATH], szShellTest[20];
  473.             
  474.             /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  475.             FIRSTBOX:                   
  476.             if ( box1.DoModal() == IDCANCEL )
  477.                 {
  478.                 if ( MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"Etes vous certain de vouloir\nabandonner l' installation?":
  479.                             "Are you sure you would like to abort\nthis installation program?", Dialog1Title, MB_YESNO | MB_DEFBUTTON2 | MB_ICONQUESTION ) == IDYES )
  480.                     goto END;
  481.                 else
  482.                     goto FIRSTBOX;
  483.                 }
  484.             
  485.             SECONDBOX:
  486.             // ----- Put Panel 2 if necessary -----
  487.             if ( iPanel2Bitmap == 0 )
  488.                 {
  489.                 if ( szPanel2Title.GetLength() > 0 )
  490.                     {
  491.                     SetTextLogo( szPanel2Title, szPanel2TitleFont, iPanel2TitleSize, lPanel2TitleColor, bPanel2Title3D, bPanel2TitleBold );  
  492.                     if ( szPanel2Detail.GetLength() > 0 )
  493.                         SetTextDetail( szPanel2Detail, szPanel2DetailFont, iPanel2DetailSize, lPanel2DetailColor, bPanel2Detail3D, bPanel2DetailBold );  
  494.                     SetLogoType( TRUE );
  495.                     SendMessage( WM_PAINT );
  496.                     }
  497.                 }
  498.             else 
  499.                 {
  500.                 SetLogo( AfxGetInstanceHandle(), iPanel2Bitmap );
  501.                 SetLogoType( FALSE );
  502.                 SendMessage( WM_PAINT );
  503.                 }
  504.             
  505.             test2 = box2.DoModal();
  506.             if ( test2 == IDCANCEL )
  507.                 {
  508.                 if ( MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"Etes vous certain de vouloir\nabandonner l' installation?":
  509.                             "Are you sure you would like to abort\nthis installation program?", Dialog1Title, MB_YESNO | MB_DEFBUTTON2 | MB_ICONQUESTION ) == IDYES )
  510.                     goto END;
  511.                 goto SECONDBOX;
  512.                 }
  513.             else if ( test2 == IDCHANGEPATH )
  514.                 goto FIRSTBOX;
  515.             // ----- Put Panel 3 if necessary -----
  516.             if ( iPanel3Bitmap == 0 )
  517.                 {
  518.                 if ( szPanel3Title.GetLength() > 0 )
  519.                     {
  520.                     SetTextLogo( szPanel3Title, szPanel3TitleFont, iPanel3TitleSize, lPanel3TitleColor, bPanel3Title3D, bPanel3TitleBold );  
  521.                     if ( szPanel3Detail.GetLength() > 0 )
  522.                         SetTextDetail( szPanel3Detail, szPanel3DetailFont, iPanel3DetailSize, lPanel3DetailColor, bPanel3Detail3D, bPanel3DetailBold );  
  523.                     SetLogoType( TRUE );
  524.                     SendMessage( WM_PAINT );
  525.                     }
  526.                 }
  527.             else 
  528.                 {
  529.                 SetLogo( AfxGetInstanceHandle(), iPanel3Bitmap );
  530.                 SetLogoType( FALSE );
  531.                 SendMessage( WM_PAINT );
  532.                 }
  533.             // log file ------
  534.             if ( bUseLogFile )
  535.                 {
  536.                 szLogFile = UserPath + szLogFileName;
  537.                 SetLogFile( szLogFile );
  538.                 }
  539.             // Select sections
  540.             for ( i = 0 ; i <  NumberOfSections ; i++ )
  541.                 {
  542.                 if ( Section[i].bSelected )
  543.                     {
  544.                     if ( Section[i].Directory.GetLength() > 0 )
  545.                         TempPath = UserPath + Section[i].Directory;
  546.                     else
  547.                         TempPath = UserPath;
  548.                     AddSectionToCopyList( Section[i].Name, TempPath );
  549.                     }
  550.                 }
  551.             // Now you can add specific section and display dialog box like this:
  552.                 /*if ( Section[0].bSelected )
  553.                     {
  554.                     GetSystemDirectory( WinDir.GetBuffer( 255 ), 253 );
  555.                     WinDir.ReleaseBuffer();
  556.                     if ( WinDir.GetLength() > 3 )
  557.                         WinDir += "\\";
  558.                     if ( iLanguage == LANGUAGE_FRENCH )
  559.                         {
  560.                         if ( MessageBox( "Installation des VBXs.\nComme vous avez choisi d' installer les VBXs,\n\
  561. il convient de les copier dans le rΘpertoire WINDOWS\\SYSTEM.\nVoulez vous faire cette copie?", "VBXs Setup", MB_YESNO | MB_ICONQUESTION ) == IDYES )
  562.                           AddSectionToCopyList( "SYSTEMVBX", WinDir );
  563.                           }
  564.                     else
  565.                         {
  566.                         if ( MessageBox( "VBX Studio VBXs installation.\nAs you choose to install the VBXs, this setup program will also\n\
  567. put a copy in the WINDOWS\\SYSTEM directory.\nDo you want to do this copy?", "VBXs Setup", MB_YESNO | MB_ICONQUESTION ) == IDYES )
  568.                           AddSectionToCopyList( "SYSTEMVBX", WinDir );
  569.                           }
  570.                     }*/
  571.                     
  572.             
  573.             /////////////////////////////////////////////////////////// Specific //////////////////////////////////////////////////////////////////////
  574.             //     We always add the [CTL3D] section:
  575.             //  This section contains CTL3DV2.DLL which must be installed in the SYSTEM directory if not found.
  576.             /////////////////////////////////////////////////////////// Specific //////////////////////////////////////////////////////////////////////
  577.             GetSystemDirectory( TempPath.GetBuffer(255), 255 );
  578.             TempPath.ReleaseBuffer();
  579.             AddSectionToCopyList( "CTL3D", TempPath );
  580.  
  581.             
  582.             iResult = GoSetup( m_hWnd, TRUE );        // TRUE because we will use FINISH.EXE to clean up the temp dir when setup is complete
  583.             
  584.             
  585.             
  586.             if ( iResult == SETUP_SUCCESSFUL )
  587.                 {   
  588.                 /////////////////////////////////////////////////////////// Specific //////////////////////////////////////////////////////////////////////
  589.                  //    In this case we are using 2 MAIN.MAK files: One for the VB template and another
  590.                  //    for the VC template: So we renamed the VB MAIN.MAK into VBMAIN.MAK to build this
  591.                  //    setup. Now we have to rename this file if the user choose to install the VB template
  592.                  /////////////////////////////////////////////////////////// Specific //////////////////////////////////////////////////////////////////////
  593.                  if ( Section[2].bSelected )        
  594.                     {
  595.                     SrcHelpFile = UserPath;
  596.                     SrcHelpFile += "TEMPLATE\\VB\\VBMAIN.MAK";
  597.                     DestHelpFile = UserPath;
  598.                     DestHelpFile += "TEMPLATE\\VB\\MAIN.MAK";
  599.                     if ( DoesFileExist( SrcHelpFile, TRUE ) )
  600.                         {
  601.                         if ( DoesFileExist( DestHelpFile, TRUE ) )
  602.                             DeleteFile( DestHelpFile );
  603.                         RenameFile( SrcHelpFile, DestHelpFile );
  604.                         }
  605.                     }
  606.                     
  607.             /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  608.             if ( Section[0].bSelected )        
  609.                 {
  610.                 if ( bInstallIcons )
  611.                     {
  612.                     Message = ( iLanguage == LANGUAGE_FRENCH )?"Souhaitez vous installer les ic⌠nes de ":"Would you like to install the ";
  613.                     Message += szProductName;
  614.                     Message += ( iLanguage == LANGUAGE_FRENCH )?"?":" icons?";
  615.                     if ( MessageBox( Message, Dialog1Title, MB_YESNO | MB_ICONQUESTION) == IDYES )            
  616.                         {
  617.                         // Maybe the icon installation will fail if ProgMan was replaced with a customized shell....
  618.                         GetWindowsDirectory( szTempBatch, _MAX_PATH );
  619.                         if ( szTempBatch[lstrlen( szTempBatch ) - 1 ] != '\\' ) 
  620.                             lstrcat( szTempBatch, "\\" );
  621.                         lstrcat( szTempBatch, "SYSTEM.INI" );
  622.                         GetPrivateProfileString( "boot", "shell", "", szShellTest, 20, szTempBatch );
  623.                         if ( !bWin4 )
  624.                             if ( (lstrcmpi( szShellTest, "PROGMAN" ) != 0 ) && (lstrcmpi( szShellTest, "PROGMAN.EXE" ) != 0 ) )
  625.                                 {
  626.                                 if ( iLanguage == LANGUAGE_FRENCH )
  627.                                     Message = "Le gestionnaire de programmes n' est pas prΘsent!\nL' installation des ic⌠nes peut Θchouer et une installation manuelle\ndes ic⌠nes sera peut Ωtre nΘcessaire.";
  628.                                 else
  629.                                     Message = "ProgMan not detected!\nIcons setup can fail, maybe a manual icons installation will be required.";
  630.                                 MessageBox( Message, Dialog1Title, MB_OK | MB_ICONEXCLAMATION );
  631.                                 }
  632.                         for ( i = 0 ; i < NumberOfIcons ; i++ )
  633.                             {
  634.                             IconPath = UserPath + IconEntry[i].szIconRelativeName;
  635.                             if ( DoesFileExist( IconPath, TRUE ) )
  636.                                 {
  637.                                 if ( IconEntry[i].EIconText.GetLength() > 0 )
  638.                                     {
  639.                                     AddItemToProgman( ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FGroupName : IconEntry[i].EGroupName, IconPath,
  640.                                                                       ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FIconName : IconEntry[i].EIconName,
  641.                                                                       ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FIconText : IconEntry[i].EIconText );
  642.                                     ShowProgmanGroup( ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FGroupName : IconEntry[i].EGroupName );
  643.                                     }
  644.                                 else
  645.                                     {               
  646.                                     AddProgmanGroup(( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FGroupName : IconEntry[i].EGroupName);
  647.                                     ShowProgmanGroup( ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FGroupName : IconEntry[i].EGroupName );
  648.                                     AddProgmanItem( IconPath, ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FIconName : IconEntry[i].EIconName );
  649.                                     }
  650.                               }
  651.                              }
  652.                         ShowWindow(SW_SHOWNORMAL );
  653.                        }
  654.                     }
  655.                 }
  656.             
  657.             /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  658.             if ( bMakeAssociation )
  659.                 {
  660.                 for ( i = 0; i < NumberOfAsso; i++ )
  661.                     {
  662.                     DestHelpFile = UserPath + WFAsso[i].szProgName;
  663.                     if ( DoesFileExist( DestHelpFile, TRUE ))
  664.                         CreateWinFileAssociation( WFAsso[i].szExt, DestHelpFile );
  665.                     }
  666.                 }
  667.             if ( szLaunch != "" )
  668.                 {
  669.                 DestHelpFile = szLaunch;
  670.                 DestHelpFile = DestHelpFile.Right( 3 );
  671.                 if ( DestHelpFile == "HLP" )
  672.                     {
  673.                     DestHelpFile = UserPath + szLaunch;
  674.                     if ( DoesFileExist( DestHelpFile, TRUE ))
  675.                         {
  676.                         if ( MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"L' installation est terminΘe.\nVoulez vous parcourir le fichier\nd'aide maintenant?":
  677.                             "This installation is complete.\nWould you like to have a look at\nthe help file right now?", Dialog1Title ,MB_YESNO | MB_ICONQUESTION ) == IDYES )
  678.                             ::WinHelp( NULL, DestHelpFile, HELP_CONTENTS, 0L );
  679.                         }
  680.                     }
  681.                 else
  682.                     {
  683.                     DestHelpFile = UserPath + szLaunch;
  684.                     if ( DoesFileExist( DestHelpFile, TRUE ))
  685.                         {
  686.                         if ( MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"L' installation est terminΘe.\nVoulez vous lancer le programme maintenant?":
  687.                             "This installation is complete.\nWould you like to have a look at the program right now?", Dialog1Title ,MB_YESNO | MB_ICONQUESTION ) == IDYES )
  688.                             WinExec( DestHelpFile, SW_SHOW );
  689.                         }                                                       
  690.                     }
  691.                 }
  692.             }// Sucessful installation
  693.         else
  694.             {
  695.             MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"L' installation est incomplΦte.\nPour utiliser ce produit, vous devrez l' installer α nouveau.":
  696.             "Installation not complete.\nPlease to use this program, install it again.", Dialog1Title, MB_OK | MB_ICONEXCLAMATION );
  697.             }
  698.         
  699.         END:    
  700.             PostMessage( WM_CLOSE );                          
  701.             return TRUE;
  702.             }
  703.             
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  711. //                                                                        Implementation - Generic                                                                                                                        //
  712. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  713.  
  714. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  715. // CSetupApp
  716. // Application implementation
  717. //
  718.             
  719.             // ----------------------------------------------------------
  720.             //  Message MAP
  721.             // ----------------------------------------------------------
  722.             BEGIN_MESSAGE_MAP(CSetupApp, CWinApp)
  723.                 //{{AFX_MSG_MAP(CSetupApp)
  724.                     // NOTE - the ClassWizard will add and remove mapping macros here.
  725.                     //    DO NOT EDIT what you see in these blocks of generated code !
  726.                 //}}AFX_MSG_MAP
  727.                 // Standard file based document commands
  728.             END_MESSAGE_MAP()
  729.             
  730.         
  731.         
  732.             
  733.             // ----------------------------------------------------------
  734.             //  Application instanciation
  735.             // ----------------------------------------------------------
  736.             CSetupApp NEAR theApp;
  737.             
  738.             // ----------------------------------------------------------
  739.             //  Instance Initialization
  740.             // ----------------------------------------------------------
  741.             BOOL CSetupApp::InitInstance()
  742.                 {
  743.                 bWin4 = SetupHasWin4Look();        
  744.                 if ( !bWin4 )
  745.                     SetDialogBkColor();                // set dialog background color to gray
  746.                 // Always uses CTL3D with Win16 apps.
  747.                 Ctl3dRegister( AfxGetInstanceHandle() );        // See CTL3D API
  748.                 Ctl3dAutoSubclass( AfxGetInstanceHandle() );        // See CTL3D API
  749.                 EnableVBX();                          // Initialize VBX support
  750.                 UserConfigSize = 0L;
  751.                 // We need to retrieve the COMMAND line arguments
  752.                 if (m_lpCmdLine[0] != '\0')
  753.                     {
  754.                     lstrcpy( (LPSTR)szOriginalPath, m_lpCmdLine );     // has replaced the old <ExtractParameter> function
  755.                     if ( GetWindowsDirectory( (LPSTR)szTempSetupPath, _MAX_PATH ) )
  756.                         {
  757.                         if ( szTempSetupPath[ lstrlen( szTempSetupPath )-1] == '\\' )
  758.                             lstrcat( (LPSTR)szTempSetupPath, "~SSETUP\\" );
  759.                         else
  760.                             lstrcat( (LPSTR)szTempSetupPath, "\\~SSETUP\\" );
  761.                         }
  762.                     else                   
  763.                         {
  764.                         ::MessageBox( NULL, "Internal error.\nCan' t find WINDOWS directory.", Dialog1Title, MB_OK | MB_ICONSTOP );
  765.                         return FALSE;
  766.                         }
  767.                     }
  768.                 else
  769.                     {
  770.                     ::MessageBox( NULL, "This program cannot be launched directly.\nSETUP.EXE must be used to to this.\n", Dialog1Title, MB_OK | MB_ICONSTOP );
  771.                     return FALSE;
  772.                     }
  773.                 CFirst boite1;
  774.                 boite1.DoModal();
  775.                 if ( bIsSetupOK )
  776.                     {
  777.                     CMain MainBox;
  778.                     MainBox.DoModal();
  779.                     }
  780.                 return TRUE;
  781.                 }
  782.             
  783.             // ----------------------------------------------------------
  784.             //  Intance Exit ( like WEP )
  785.             // ----------------------------------------------------------
  786.             int CSetupApp::ExitInstance()
  787.                 {
  788.                 Ctl3dUnregister( AfxGetInstanceHandle() );
  789.                 DeleteSystemDir(  );
  790.                 return CWinApp::ExitInstance();
  791.                 }
  792.             
  793.             // ----------------------------------------------------------
  794.             //  VBX Event MAP (none)
  795.             // ----------------------------------------------------------
  796.             //{{AFX_VBX_REGISTER_MAP()
  797.             //}}AFX_VBX_REGISTER_MAP
  798.             
  799.             
  800.             
  801.             
  802.             
  803.             
  804. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  805. // CFirst dialog - Splash style and initialization managment
  806. //
  807.             
  808.             
  809.             
  810.             
  811.             // ----------------------------------------------------------
  812.             //  Constructor
  813.             // ----------------------------------------------------------
  814.             CFirst::CFirst(CWnd* pParent /*=NULL*/)
  815.                 : CDialog(CFirst::IDD, pParent)
  816.                 {
  817.                 //{{AFX_DATA_INIT(CFirst)
  818.                     // NOTE: the ClassWizard will add member initialization here
  819.                 //}}AFX_DATA_INIT
  820.                 }
  821.             
  822.             
  823.             
  824.             // ----------------------------------------------------------
  825.             //  Data Exchange
  826.             // ----------------------------------------------------------
  827.             void CFirst::DoDataExchange(CDataExchange* pDX)
  828.                 {
  829.                 CDialog::DoDataExchange(pDX);
  830.                 //{{AFX_DATA_MAP(CFirst)
  831.                     // NOTE: the ClassWizard will add DDX and DDV calls here
  832.                 //}}AFX_DATA_MAP
  833.                 }
  834.             
  835.             // ----------------------------------------------------------
  836.             //  Message MAP
  837.             // ----------------------------------------------------------
  838.             BEGIN_MESSAGE_MAP(CFirst, CDialog)
  839.                 //{{AFX_MSG_MAP(CFirst)
  840.                 ON_MESSAGE( PM_FIRST, OnFirstPrivate )
  841.                 ON_WM_CLOSE()
  842.                 ON_WM_DESTROY()
  843.                 //}}AFX_MSG_MAP
  844.             END_MESSAGE_MAP()
  845.             
  846.             
  847.             
  848.             // ----------------------------------------------------------
  849.             //  WM_INITDIALOG
  850.             //  Interface managment and Call OnFirstPrivate
  851.             // ----------------------------------------------------------
  852.             BOOL CFirst::OnInitDialog()
  853.                 {
  854.                 CDialog::OnInitDialog();
  855.                 if ((hfontDlg = (HFONT) SendMessage(WM_GETFONT) )) 
  856.                     {
  857.                     if (::GetObject(hfontDlg, sizeof(LOGFONT), (LPSTR) &lFont)) 
  858.                         {
  859.                         lFont.lfWeight = FW_NORMAL;
  860.                         if (hfontDlg = CreateFontIndirect((LPLOGFONT) &lFont)) 
  861.                             SendDlgItemMessage( IDC_STATIC1, WM_SETFONT, (WPARAM) hfontDlg, 0);
  862.                         }
  863.                     }
  864.                 SetWindowText( Dialog1Title );
  865.                 SetClassWord( m_hWnd, GCW_HICON, (WORD)( (AfxGetApp())->LoadIcon( IDR_MAINFRAME )) );
  866.                 Ctl3dSubclassDlg( m_hWnd, CTL3D_ALL );
  867.                 CenterDialogBox( m_hWnd );
  868.                 BringWindowToTop();
  869.                 FirstCanClose = FALSE;
  870.                 //::PostMessage( m_hWnd, PM_FIRST, 0, 0L );
  871.                 SendMessage( PM_FIRST );
  872.                 return TRUE;  // return TRUE  unless you set the focus to a control
  873.                 }
  874.             
  875.             
  876.             // ----------------------------------------------------------
  877.             //  PM_FIRST private message function
  878.             //  Guess the user Language 
  879.             //  Set interface
  880.             //  Call SetupInitialize
  881.             // ----------------------------------------------------------
  882.             afx_msg LRESULT CFirst::OnFirstPrivate( WPARAM wParam, LPARAM lParam )
  883.                 {
  884.                 /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  885.                 static char far szTemp[6];                                                                                                
  886.                 // Have a look in WIN.INI for Language detection
  887.                 ::GetProfileString( "intl", "sLanguage", "", (LPSTR)szTemp, 4 );
  888.                 AnsiUpper( szTemp );
  889.                 if (lstrcmp( szTemp, "FRA" )== 0 )
  890.                     iLanguage = LANGUAGE_FRENCH;
  891.                 else
  892.                     iLanguage = LANGUAGE_ENGLISH;
  893.                 bIsSetupOK = SetupInitialize( szYourName, szYourPassword, iLanguage, (LPSTR)szOriginalPath, (LPSTR)szTempSetupPath );
  894.                 SetupSetTitle( szSetupBoxTitle );
  895.                 if ( bUseSharedBatch )
  896.                     {                                   
  897.                     CString szUserBatchFile, szUserBatchDir;
  898.                     GetWindowsDirectory( szUserBatchFile.GetBuffer(182), 180 );
  899.                     szUserBatchFile.ReleaseBuffer();
  900.                     szUserBatchFile = szUserBatchFile.Left( 3 );
  901.                     szUserBatchDir = szUserBatchFile;
  902.                     szUserBatchFile += ( szBatchFile != "") ? szBatchFile : "SYSSETUP.TMP\\SYSSETUP.BAT" ;
  903.                     szUserBatchDir += ( szBatchDir != "")? szBatchDir : "SYSSETUP.TMP\\";
  904.                     SetSharedBatchFile( szUserBatchFile, szUserBatchDir );
  905.                     }
  906.                 SetPatternBrushStandard( iBackgroundPaper );
  907.                 SetupSetBeepMode ( bBeepMode );            // Select or not the BEEP mode
  908.                 SetVerifyMode( bVerifyMode );            // Select or unselect the File Size Verification mode ( if size is bad, setup will abort ).
  909.                 // ---- panel 1 ----
  910.                 if ( iPanel1Bitmap == 0 )
  911.                     {
  912.                     if ( szPanel1Title.GetLength() > 0 )
  913.                         {
  914.                         SetTextLogo( szPanel1Title, szPanel1TitleFont, iPanel1TitleSize, lPanel1TitleColor, bPanel1Title3D, bPanel1TitleBold );  
  915.                         if ( szPanel1Detail.GetLength() > 0 )
  916.                             SetTextDetail( szPanel1Detail, szPanel1DetailFont, iPanel1DetailSize, lPanel1DetailColor, bPanel1Detail3D, bPanel1DetailBold );  
  917.                         SetLogoType( TRUE );
  918.                         }
  919.                     }
  920.                 else 
  921.                     {
  922.                     SetLogo( AfxGetInstanceHandle(), iPanel1Bitmap );
  923.                     SetLogoType( FALSE );
  924.                     }
  925.                 FirstCanClose = TRUE;
  926.                 PostMessage( WM_CLOSE );
  927.                 return TRUE;
  928.                 }    
  929.             
  930.             
  931.             // ----------------------------------------------------------
  932.             //  WM_CLOSE
  933.             //    Do not close during Initialization
  934.             // ----------------------------------------------------------
  935.             void CFirst::OnClose()
  936.                 {
  937.                 if ( FirstCanClose )                     
  938.                     CDialog::OnClose();
  939.                 else
  940.                     MessageBeep( -1 );            
  941.                 }
  942.                 
  943.                 
  944.                 
  945.             
  946.             
  947. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  948. // CMain dialog - We use this dialog box as the main screen
  949. //
  950.             
  951.             // ----------------------------------------------------------
  952.             //  Constructor
  953.             // ----------------------------------------------------------
  954.             CMain::CMain(CWnd* pParent /*=NULL*/)
  955.                 : CDialog(CMain::IDD, pParent)
  956.                 {
  957.                 //{{AFX_DATA_INIT(CMain)
  958.                     // NOTE: the ClassWizard will add member initialization here
  959.                 //}}AFX_DATA_INIT
  960.                 }
  961.             
  962.             // ----------------------------------------------------------
  963.             //  Data Exchange
  964.             // ----------------------------------------------------------
  965.             void CMain::DoDataExchange(CDataExchange* pDX)
  966.                 {
  967.                 CDialog::DoDataExchange(pDX);
  968.                 //{{AFX_DATA_MAP(CMain)
  969.                     // NOTE: the ClassWizard will add DDX and DDV calls here
  970.                 //}}AFX_DATA_MAP
  971.                 }
  972.             
  973.             // ----------------------------------------------------------
  974.             //  Message MAP
  975.             // ----------------------------------------------------------
  976.             BEGIN_MESSAGE_MAP(CMain, CDialog)
  977.                 //{{AFX_MSG_MAP(CMain)
  978.                 ON_MESSAGE( PM_FIRST2, OnFirstPrivate )
  979.                 ON_MESSAGE( SN_NEWDISKREQUIRED, OnNewDisk )
  980.                 ON_WM_PAINT()
  981.                 ON_WM_NCPAINT()
  982.                 //}}AFX_MSG_MAP
  983.             END_MESSAGE_MAP()
  984.             
  985.             
  986.             
  987.             
  988.             
  989.             // ----------------------------------------------------------
  990.             //  WM_INITDIALOG
  991.             //    Call CMain::OnFirstPrivate
  992.             // ----------------------------------------------------------
  993.             BOOL CMain::OnInitDialog()
  994.                 {
  995.                 CDialog::OnInitDialog();
  996.                 SetClassWord( m_hWnd, GCW_HICON, (WORD)( (AfxGetApp())->LoadIcon( IDR_MAINFRAME )) );
  997.                 SetWindowText( Dialog1Title );
  998.                 BringWindowToTop();
  999.                 PostMessage( PM_FIRST2 );
  1000.                 return TRUE;  // return TRUE  unless you set the focus to a control
  1001.                 }
  1002.             
  1003.             
  1004.             
  1005.             
  1006.             
  1007.             // ----------------------------------------------------------
  1008.             //  SN_NEWDISKREQUIRED
  1009.             //    You will receive this message
  1010.             //    when CSetup shows the New Disk
  1011.             //    Required dialog box.
  1012.             // ----------------------------------------------------------
  1013.             afx_msg LRESULT CMain::OnNewDisk( WPARAM wParam, LPARAM lParam )
  1014.                 {
  1015.                 return TRUE;
  1016.                 };
  1017.             
  1018.             
  1019.             // ----------------------------------------------------------
  1020.             //  WM_PAINT
  1021.             //    Call ShowMainWindow CSETUP.DLL function
  1022.             // ----------------------------------------------------------
  1023.             void CMain::OnPaint()
  1024.                 {                                 
  1025.                 CPaintDC dc(this);                                                                                                                
  1026.                 RedrawWindow( NULL, NULL, RDW_NOFRAME | RDW_NOERASE );  // To avoid flashing
  1027.                 ShowMainWindow( m_hWnd );      // The main function wich paint your window as a Setup Like window ( for PAINT )
  1028.                 RedrawWindow( NULL, NULL, RDW_NOFRAME | RDW_NOERASE );  // To avoid flashing
  1029.                 }
  1030.             
  1031.             
  1032.             
  1033.             // ----------------------------------------------------------
  1034.             //  WM_PAINT
  1035.             //    Call ShowMainWindow CSETUP.DLL function
  1036.             // ----------------------------------------------------------
  1037.             void CMain::OnNcPaint()
  1038.                 {
  1039.                 RedrawWindow( NULL, NULL, RDW_NOERASE | RDW_VALIDATE );  // To avoid flashing 
  1040.                 ShowMainWindow( m_hWnd );      // The main function wich paint your window as a Setup Like window ( for PAINT )
  1041.                 RedrawWindow( NULL, NULL, RDW_NOERASE | RDW_VALIDATE );  // To avoid flashing 
  1042.                 }
  1043.  
  1044.  
  1045.  
  1046.  
  1047.     
  1048.  
  1049.  
  1050.  
  1051.  
  1052. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1053. // CChoice1 dialog allows the user to choose Language and main Destination PATH
  1054. //
  1055.             
  1056.             // ----------------------------------------------------------
  1057.             //  Constructor
  1058.             // ----------------------------------------------------------
  1059.             CChoice1::CChoice1(CWnd* pParent /*=NULL*/)
  1060.                 : CDialog(CChoice1::IDD, pParent)
  1061.             {
  1062.                 //{{AFX_DATA_INIT(CChoice1)
  1063.                     // NOTE: the ClassWizard will add member initialization here
  1064.                 //}}AFX_DATA_INIT
  1065.             }
  1066.             
  1067.             
  1068.             // ----------------------------------------------------------
  1069.             //  Data Exchange ( not used )
  1070.             // ----------------------------------------------------------
  1071.             void CChoice1::DoDataExchange(CDataExchange* pDX)
  1072.             {
  1073.                 CDialog::DoDataExchange(pDX);
  1074.                 //{{AFX_DATA_MAP(CChoice1)
  1075.                     // NOTE: the ClassWizard will add DDX and DDV calls here
  1076.                 //}}AFX_DATA_MAP
  1077.             }
  1078.             
  1079.             // ----------------------------------------------------------
  1080.             //  Message MAP
  1081.             // ----------------------------------------------------------
  1082.             BEGIN_MESSAGE_MAP(CChoice1, CDialog)
  1083.                 //{{AFX_MSG_MAP(CChoice1)
  1084.                 ON_BN_CLICKED(IDC_RADIOENGLISH, OnClickedRadioenglish)
  1085.                 ON_BN_CLICKED(IDC_RADIOFRENCH, OnClickedRadiofrench)
  1086.                 ON_EN_CHANGE(IDC_EDITSRCPATH, OnChangeEditsrcpath)
  1087.                 ON_WM_DESTROY()
  1088.     ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
  1089.     //}}AFX_MSG_MAP
  1090.             END_MESSAGE_MAP()
  1091.             
  1092.             
  1093.             
  1094.             
  1095.             
  1096.             // ----------------------------------------------------------
  1097.             //  WM_COMMAND:ONLANGUAGE
  1098.             //  Change the language
  1099.             // ----------------------------------------------------------
  1100.             void CChoice1::OnClickedRadioenglish()
  1101.                 {
  1102.                 /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  1103.                 SetupSetLanguage( LANGUAGE_ENGLISH );
  1104.                 iLanguage = LANGUAGE_ENGLISH;
  1105.                 SetDlgItemText( IDC_GROUPLANGUAGE, "Language... ");
  1106.                 CString ProductName;
  1107.                 ProductName = ( iLanguage == LANGUAGE_FRENCH )? "Indiquer le rΘpertoire o∙ vous souhaitez installer ": "Please, give the directory in which you would like to install ";
  1108.                 ProductName += szProductName;
  1109.                 ProductName += ( iLanguage == LANGUAGE_FRENCH )?" et cliquer sur' OK'":" and click on 'OK'";
  1110.                 SetDlgItemText( IDC_TEXTE, ProductName );
  1111.                 SetDlgItemText( IDCANCEL, "&Abort");
  1112.                 }
  1113.             
  1114.             // ----------------------------------------------------------
  1115.             //  WM_COMMAND:ONLANGUAGE
  1116.             //  Change the language
  1117.             // ----------------------------------------------------------
  1118.             void CChoice1::OnClickedRadiofrench()
  1119.                 {
  1120.                 /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  1121.                 SetupSetLanguage( LANGUAGE_FRENCH );
  1122.                 iLanguage = LANGUAGE_FRENCH;
  1123.                 SetDlgItemText( IDC_GROUPLANGUAGE, "Votre langage... ");
  1124.                 CString ProductName;
  1125.                 ProductName = ( iLanguage == LANGUAGE_FRENCH )? "Indiquer le rΘpertoire o∙ vous souhaitez installer ": "Please, give the directory in which you would like to install ";
  1126.                 ProductName += szProductName;
  1127.                 ProductName += ( iLanguage == LANGUAGE_FRENCH )?" et cliquer sur 'OK'":" and click on 'OK'";
  1128.                 SetDlgItemText( IDC_TEXTE, ProductName );
  1129.                 SetDlgItemText( IDCANCEL, "&Abandonner");
  1130.                 }
  1131.             
  1132.             // ----------------------------------------------------------
  1133.             //  WM_COMMAND:ONPATH
  1134.             //  Change the path
  1135.             // ----------------------------------------------------------
  1136.             void CChoice1::OnChangeEditsrcpath()
  1137.                 {
  1138.                 /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  1139.                 CString TempDestName;
  1140.                 GetDlgItemText( IDC_EDITSRCPATH, TempDestName.GetBuffer( 162 ), 160 );
  1141.                 TempDestName.ReleaseBuffer();
  1142.                 if ( TempDestName.GetLength() < 1 )
  1143.                     GetDlgItem( IDOK)->EnableWindow( FALSE );
  1144.                 else
  1145.                     GetDlgItem( IDOK)->EnableWindow( TRUE );
  1146.                 }
  1147.  
  1148.  
  1149.  
  1150.             // ----------------------------------------------------------
  1151.             //  WM_COMMAND:ONBROWSE
  1152.             //  Change the path using a box
  1153.             // ----------------------------------------------------------
  1154.             void CChoice1::OnBrowse()
  1155.                 {
  1156.                  CString szDirValue;            
  1157.                  char szBuffer[_MAX_PATH];
  1158.                  GetDlgItem( IDC_EDITSRCPATH )->GetWindowText( szDirValue );
  1159.                  lstrcpy( szBuffer, (LPCSTR)szDirValue );
  1160.                  SetupBrowseDir( m_hWnd, szBuffer );        // 2.4 
  1161.                  GetDlgItem( IDC_EDITSRCPATH )->SetWindowText( (LPCSTR)szBuffer );
  1162.                  GetDlgItem( IDC_EDITSRCPATH )->SetFocus();
  1163.                 GetDlgItem( IDC_EDITSRCPATH )->SendMessage( EM_SETSEL, (WPARAM)TRUE, MAKELONG( 0, -1L ));
  1164.                 }
  1165.                 
  1166.                 
  1167.             // ----------------------------------------------------------
  1168.             //  WM_COMMAND:ONOK
  1169.             //  Check the path thanks to
  1170.             //    CSETUP functions
  1171.             // ----------------------------------------------------------
  1172.             void CChoice1::OnOK()
  1173.                 {
  1174.                 /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  1175.                 CString TempDestName, strKeep;
  1176.                 GetDlgItemText( IDC_EDITSRCPATH, TempDestName.GetBuffer(162), 160 );
  1177.                 TempDestName.ReleaseBuffer();
  1178.                 if ( !IsFileName( TempDestName, FILENAME_DIRWITHSLASH, CHECK_ROOTDIRSEXIST) )
  1179.                     {
  1180.                     FormatFileNameValid( TempDestName, TRUE, strKeep.GetBuffer(_MAX_PATH));
  1181.                     strKeep.ReleaseBuffer();
  1182.                     SetDlgItemText( IDC_EDITSRCPATH, strKeep );
  1183.                     }
  1184.                 if ( IsFileName( TempDestName,  FILENAME_DIRWITHSLASH, CHECK_ROOTDIRSEXIST) )
  1185.                     {
  1186.                     UserPath = TempDestName;
  1187.                     CDialog::OnOK();
  1188.                     }
  1189.                 else
  1190.                     {
  1191.                     MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"Le rΘpertoire mentionnΘ n' est pas valide.\nSi vous avez mentionnΘ des sous-rΘpertoires,\nceux-ci doivent exister.\n":
  1192.                     "Directory name is not valid.\nIf you want to use sub-directories\nthey must exist.\n", Dialog1Title, MB_OK | MB_ICONEXCLAMATION );
  1193.                     (CEdit*)(GetDlgItem( IDC_EDITSRCPATH))->SetFocus(); 
  1194.                     ((CEdit*)(GetDlgItem( IDC_EDITSRCPATH)))->SetSel( 0, -1 );
  1195.                     }
  1196.                 }
  1197.             
  1198.             
  1199.             
  1200.             
  1201.             
  1202.             
  1203.             
  1204. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1205. // CChoice2 dialog allows the user to select files to install
  1206. //
  1207.             
  1208.             // ----------------------------------------------------------
  1209.             //  Constructor
  1210.             // ----------------------------------------------------------
  1211.             CChoice2::CChoice2(CWnd* pParent /*=NULL*/)
  1212.                 : CDialog(CChoice2::IDD, pParent)
  1213.             {
  1214.                 //{{AFX_DATA_INIT(CChoice2)
  1215.                     // NOTE: the ClassWizard will add member initialization here
  1216.                 //}}AFX_DATA_INIT
  1217.             }
  1218.             
  1219.             // ----------------------------------------------------------
  1220.             //  Data Exchange ( Not use )
  1221.             // ----------------------------------------------------------
  1222.             void CChoice2::DoDataExchange(CDataExchange* pDX)
  1223.             {
  1224.                 CDialog::DoDataExchange(pDX);
  1225.                 //{{AFX_DATA_MAP(CChoice2)
  1226.                     // NOTE: the ClassWizard will add DDX and DDV calls here
  1227.                 //}}AFX_DATA_MAP
  1228.             }
  1229.             
  1230.             // ----------------------------------------------------------
  1231.             //  Message MAP
  1232.             // ----------------------------------------------------------
  1233.             BEGIN_MESSAGE_MAP(CChoice2, CDialog)
  1234.                 //{{AFX_MSG_MAP(CChoice2)
  1235.                 ON_BN_CLICKED(IDB_CHANGEPATH, OnClickedChangepath)
  1236.                 ON_BN_CLICKED(IDC_CHECK1, OnClickedCheck1)
  1237.                 ON_BN_CLICKED(IDC_CHECK2, OnClickedCheck2)
  1238.                 ON_BN_CLICKED(IDC_CHECK3, OnClickedCheck3)
  1239.                 ON_BN_CLICKED(IDC_CHECK4, OnClickedCheck4)
  1240.                 ON_BN_CLICKED(IDC_CHECK5, OnClickedCheck5)
  1241.                 ON_BN_CLICKED(IDC_CHECK6, OnClickedCheck6)
  1242.                 ON_BN_CLICKED(IDC_CHECK7, OnClickedCheck7)
  1243.                 ON_BN_CLICKED(IDC_CHECK8, OnClickedCheck8)
  1244.                 ON_BN_CLICKED(IDC_CHECK9, OnClickedCheck9)
  1245.                 ON_BN_CLICKED(IDC_CHECK10, OnClickedCheck10)
  1246.                 ON_BN_CLICKED(IDC_CHECK11, OnClickedCheck11)
  1247.                 ON_BN_CLICKED(IDC_CHECK12, OnClickedCheck12)
  1248.                 ON_BN_CLICKED(IDC_CHECK13, OnClickedCheck13)
  1249.                 ON_BN_CLICKED(IDC_CHECK14, OnClickedCheck14)
  1250.                 ON_BN_CLICKED(IDC_CHECK15, OnClickedCheck15)
  1251.     ON_WM_DESTROY()
  1252.     //}}AFX_MSG_MAP
  1253.             END_MESSAGE_MAP()
  1254.             
  1255.             
  1256.             
  1257.             
  1258.             // ----------------------------------------------------------
  1259.             //  WM_INITDIALOG
  1260.             //  Check boxes managment
  1261.             // ----------------------------------------------------------
  1262.             BOOL CChoice2::OnInitDialog()
  1263.                 {
  1264.                 /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  1265.                 register int i=0;
  1266.                 CDialog::OnInitDialog();
  1267.                 SetWindowText( Dialog3Title );
  1268.                 if ((hfontDlg = (HFONT) SendMessage(WM_GETFONT) )) 
  1269.                     {
  1270.                     if (::GetObject(hfontDlg, sizeof(LOGFONT), (LPSTR) &lFont)) 
  1271.                         {
  1272.                         lFont.lfWeight = FW_NORMAL;
  1273.                         if (hfontDlg = CreateFontIndirect((LPLOGFONT) &lFont)) 
  1274.                             {
  1275.                             SendDlgItemMessage( IDC_CHECK1, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1276.                             SendDlgItemMessage( IDC_CHECK2, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1277.                             SendDlgItemMessage( IDC_CHECK3, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1278.                             SendDlgItemMessage( IDC_CHECK4, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1279.                             SendDlgItemMessage( IDC_CHECK5, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1280.                             SendDlgItemMessage( IDC_CHECK6, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1281.                             SendDlgItemMessage( IDC_CHECK7, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1282.                             SendDlgItemMessage( IDC_CHECK8, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1283.                             SendDlgItemMessage( IDC_CHECK9, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1284.                             SendDlgItemMessage( IDC_CHECK10, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1285.                             SendDlgItemMessage( IDC_CHECK11, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1286.                             SendDlgItemMessage( IDC_CHECK12, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1287.                             SendDlgItemMessage( IDC_CHECK13, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1288.                             SendDlgItemMessage( IDC_CHECK14, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1289.                             SendDlgItemMessage( IDC_CHECK15, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1290.                             SendDlgItemMessage( IDC_K1, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1291.                             SendDlgItemMessage( IDC_K2, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1292.                             SendDlgItemMessage( IDC_K3, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1293.                             SendDlgItemMessage( IDC_K4, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1294.                             SendDlgItemMessage( IDC_K5, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1295.                             SendDlgItemMessage( IDC_K6, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1296.                             SendDlgItemMessage( IDC_K7, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1297.                             SendDlgItemMessage( IDC_K8, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1298.                             SendDlgItemMessage( IDC_K9, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1299.                             SendDlgItemMessage( IDC_K10, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1300.                             SendDlgItemMessage( IDC_K11, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1301.                             SendDlgItemMessage( IDC_K12, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1302.                             SendDlgItemMessage( IDC_K13, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1303.                             SendDlgItemMessage( IDC_K14, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1304.                             SendDlgItemMessage( IDC_K15, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1305.                             SendDlgItemMessage( IDC_GROUP, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1306.                             SendDlgItemMessage( IDC_TEXTECSIZE, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1307.                             SendDlgItemMessage( IDC_KCONFIG, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1308.                             SendDlgItemMessage( IDC_TEXTETOTALSIZE, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1309.                             SendDlgItemMessage( IDC_KTOTAL, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1310.                             }
  1311.                         }
  1312.                     }
  1313.                 // We resize the dialog box depending of number of items
  1314.                 RECT r, r2, r3;
  1315.                 GetWindowRect( &r3 );
  1316.                 GetDlgItem( IDC_CHECK1 )->GetWindowRect( &r2 );
  1317.                 GetDlgItem( IDC_GROUP )->GetWindowRect( &r );
  1318.                 GetDlgItem( IDC_GROUP )->SetWindowPos( NULL, 0,0, r.right-r.left, r.bottom - ( ((15- NumberOfSections)<9?15- NumberOfSections:9 ) * (r2.bottom-r2.top) )-r.top-12, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOMOVE );
  1319.                 GetDlgItem( IDC_TEXTECSIZE )->GetWindowRect( &r );
  1320.                 GetDlgItem( IDC_TEXTECSIZE )->SetWindowPos( NULL, r.left - r3.left, 2 + r.top -( ( (16 -NumberOfSections)<10?16-NumberOfSections:10)  * (r2.bottom-r2.top) )-r3.top-20 , 0, 0, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOSIZE );
  1321.                 GetDlgItem( IDC_KCONFIG )->GetWindowRect( &r );
  1322.                 GetDlgItem( IDC_KCONFIG )->SetWindowPos( NULL, r.left- r3.left, 2 + r.top -( ((16 -NumberOfSections)<10?16-NumberOfSections:10) * (r2.bottom-r2.top) )-r3.top -20 , 0, 0, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOSIZE );
  1323.                 GetDlgItem( IDC_TEXTETOTALSIZE )->GetWindowRect( &r );
  1324.                 GetDlgItem( IDC_TEXTETOTALSIZE )->SetWindowPos( NULL, r.left- r3.left, 2 + r.top -( ((16 -NumberOfSections)<10?16-NumberOfSections:10) * (r2.bottom-r2.top) )-r3.top -20 , 0, 0, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOSIZE );
  1325.                 GetDlgItem( IDC_KTOTAL )->GetWindowRect( &r );
  1326.                 GetDlgItem( IDC_KTOTAL )->SetWindowPos( NULL, r.left- r3.left, 2 + r.top -( ((16 -NumberOfSections)<10?16-NumberOfSections:10) * (r2.bottom-r2.top) )-r3.top -20 , 0, 0, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOSIZE );
  1327.                 SetWindowPos( NULL, 0,0, r3.right-r3.left, r3.bottom - ( ((16 -NumberOfSections)<10?16-NumberOfSections:10) * (r2.bottom-r2.top) )-r3.top+20, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOMOVE );
  1328.                     
  1329.                 // Set the dialog box value
  1330.                 CString TempLabel;                                         
  1331.                 UserConfigSize = 0L;
  1332.                 for ( i = 0 ; i <  NumberOfSections ; i++ )
  1333.                     {
  1334.                     if ( Section[i].Name.GetLength()> 0 )
  1335.                         {
  1336.                         TempLabel = ( iLanguage == LANGUAGE_FRENCH)?Section[i].FLabel : Section[i].ELabel;
  1337.                         if ( TempLabel.GetLength() > 0 )
  1338.                             {
  1339.                             GetDlgItem( 120 + i )->ShowWindow( SW_SHOW );
  1340.                             GetDlgItem( 150 + i )->ShowWindow( SW_SHOW );
  1341.                             SetDlgItemText( 120 + i, TempLabel );        // --> label
  1342.                             CheckDlgButton( 120 + i, Section[i].bSelected );        
  1343.                             if ( Section[i].bSelected )
  1344.                                 {
  1345.                                 UserConfigSize += Section[i].lSize;
  1346.                                 _ltoa( UserConfigSize, TempLabel.GetBuffer(12), 10 );
  1347.                                 TempLabel.ReleaseBuffer();
  1348.                                 TempLabel += " K";
  1349.                                 SetDlgItemText( IDC_KCONFIG, TempLabel );
  1350.                                 _ltoa( Section[i].lSize, TempLabel.GetBuffer(10), 10 );
  1351.                                 TempLabel.ReleaseBuffer();
  1352.                                 }
  1353.                             else
  1354.                                 TempLabel = "0";                         
  1355.                             TempLabel += " K";
  1356.                             SetDlgItemText( 150 + i, TempLabel );
  1357.                             }
  1358.                         }
  1359.                     }                                               
  1360.                 SetClassWord( m_hWnd, GCW_HICON, (WORD)( (AfxGetApp())->LoadIcon( IDR_MAINFRAME )) );
  1361.                 Ctl3dSubclassDlg( m_hWnd, CTL3D_ALL );
  1362.                 CenterDialogBox( m_hWnd );
  1363.                 BringWindowToTop();
  1364.                 if ( iLanguage == LANGUAGE_FRENCH )
  1365.                     {
  1366.                     SetDlgItemText( IDC_GROUP, "Installer... ");
  1367.                     SetDlgItemText( IDC_TEXTECSIZE, "Taille de la sΘlection:");
  1368.                     SetDlgItemText( IDC_TEXTETOTALSIZE, "Espace disponible:");
  1369.                     SetDlgItemText( IDB_CHANGEPATH, "&RΘpertoire...");
  1370.                     SetDlgItemText( IDOK, "OK" );
  1371.                     SetDlgItemText( IDCANCEL, "Aba&ndonner" );
  1372.                     }
  1373.                 _ltoa( AskForDriveSpace( GetDriveNumber( UserPath )), TempLabel.GetBuffer(15), 10 );
  1374.                 TempLabel.ReleaseBuffer();
  1375.                 TempLabel += " K";
  1376.                 SetDlgItemText( IDC_KTOTAL, TempLabel );
  1377.                 GetDlgItem( IDC_CHECK1 )->SetFocus();
  1378.                 return FALSE; 
  1379.             }
  1380.             
  1381.             // ----------------------------------------------------------
  1382.             //  WM_COMMAND:ONPATH
  1383.             //  Save the configuration and 
  1384.             //    Call the CChoice1 Dialog box
  1385.             // ----------------------------------------------------------
  1386.             void CChoice2::OnClickedChangepath()
  1387.                 {
  1388.                 /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  1389.                 register int i = 0;
  1390.                 for ( i = 0 ; i < NumberOfSections ; i++ )
  1391.                     Section[i].bSelected = IsDlgButtonChecked( 120 + i );
  1392.                 EndDialog( IDCHANGEPATH );
  1393.                 }
  1394.             
  1395.             
  1396.             // ----------------------------------------------------------
  1397.             //  WM_COMMAND:ONOK
  1398.             //  Check available disk size
  1399.             // ----------------------------------------------------------
  1400.             void CChoice2::OnOK()
  1401.                 {
  1402.                 /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  1403.                 register int i = 0;
  1404.                 if ( UserConfigSize > AskForDriveSpace( GetDriveNumber( UserPath )) )
  1405.                     {
  1406.                     if ( iLanguage == LANGUAGE_FRENCH )
  1407.                         MessageBox("Il n' y a pas assez d' espace libre\nsur l' unitΘ de destination pour installer\nla sΘlection que vous avez choisie.\n\nVeuillez modifier votre sΘlection ou changer de rΘpertoire."
  1408.                         , Dialog1Title, MB_OK | MB_ICONEXCLAMATION );
  1409.                     else
  1410.                         MessageBox("There is not enough free space\nto install the selected files.\n\nPlease, change your selection or the destination directory."
  1411.                         , Dialog1Title, MB_OK | MB_ICONEXCLAMATION );
  1412.                     }
  1413.                 else
  1414.                     CDialog::OnOK();
  1415.                 }
  1416.             
  1417.             
  1418.             /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  1419.             // ----------------------------------------------------------
  1420.             //  WM_COMMAND:ONCHECKxx ?
  1421.             //  Check Box management
  1422.             // ----------------------------------------------------------
  1423.             void CChoice2::OnClickedCheck1()
  1424.             {
  1425.             HandleCheckBox( 1 );
  1426.             }
  1427.             void CChoice2::OnClickedCheck2()
  1428.             {
  1429.             HandleCheckBox( 2 );
  1430.             }
  1431.             void CChoice2::OnClickedCheck3()
  1432.             {
  1433.             HandleCheckBox( 3 );
  1434.             }
  1435.             void CChoice2::OnClickedCheck4()
  1436.             {
  1437.             HandleCheckBox( 4 );
  1438.             }
  1439.             void CChoice2::OnClickedCheck5()
  1440.             {
  1441.             HandleCheckBox( 5 );
  1442.             }
  1443.             void CChoice2::OnClickedCheck6()
  1444.             {
  1445.             HandleCheckBox( 6 );
  1446.             }
  1447.             void CChoice2::OnClickedCheck7()
  1448.             {
  1449.             HandleCheckBox( 7 );
  1450.             }
  1451.             void CChoice2::OnClickedCheck8()
  1452.             {
  1453.             HandleCheckBox( 8 );
  1454.             }
  1455.             void CChoice2::OnClickedCheck9()
  1456.             {
  1457.             HandleCheckBox( 9 );
  1458.             }
  1459.             void CChoice2::OnClickedCheck10()
  1460.             {
  1461.             HandleCheckBox( 10 );
  1462.             }
  1463.             void CChoice2::OnClickedCheck11()
  1464.             {
  1465.             HandleCheckBox( 11 );
  1466.             }
  1467.             void CChoice2::OnClickedCheck12()
  1468.             {
  1469.             HandleCheckBox( 12 );
  1470.             }
  1471.             void CChoice2::OnClickedCheck13()
  1472.             {
  1473.             HandleCheckBox( 13 );
  1474.             }
  1475.             void CChoice2::OnClickedCheck14()
  1476.             {
  1477.             HandleCheckBox( 14 );
  1478.             }
  1479.             void CChoice2::OnClickedCheck15()
  1480.             {
  1481.             HandleCheckBox( 15 );
  1482.             }
  1483.             
  1484.             
  1485.             void CChoice2::HandleCheckBox( int iD )
  1486.             {
  1487.             CString Temp;
  1488.             if ( IsDlgButtonChecked( 120 + iD - 1 ))
  1489.                 {
  1490.                 UserConfigSize += Section[iD - 1].lSize;
  1491.                 _ltoa( Section[iD - 1].lSize, Temp.GetBuffer( 12 ), 10 );
  1492.                 Temp.ReleaseBuffer();
  1493.                 Temp += " K";
  1494.                 SetDlgItemText( 150 + iD-1 , Temp );
  1495.                 Section[iD - 1].bSelected = TRUE;
  1496.                 }
  1497.             else
  1498.                 {
  1499.                 UserConfigSize -= Section[iD - 1].lSize;
  1500.                 SetDlgItemText(150 + iD-1, "0 K" );
  1501.                 Section[iD - 1].bSelected = FALSE;
  1502.                 }
  1503.             _ltoa( UserConfigSize, Temp.GetBuffer( 12 ), 10 );
  1504.             Temp.ReleaseBuffer();
  1505.             Temp += " K";
  1506.             SetDlgItemText( IDC_KCONFIG, Temp );
  1507.             }
  1508.             
  1509.  
  1510.             void CChoice2::OnDestroy()
  1511.             {
  1512.                 CDialog::OnDestroy();
  1513.                 ::DeleteObject( hfontDlg );
  1514.             }
  1515.             
  1516.             void CChoice1::OnDestroy()
  1517.             {
  1518.                 CDialog::OnDestroy();
  1519.                 ::DeleteObject( hfontDlg );
  1520.             }
  1521.             
  1522.             void CFirst::OnDestroy()
  1523.             {
  1524.                 CDialog::OnDestroy();
  1525.                 ::DeleteObject( hfontDlg );
  1526.             }
  1527.             
  1528.             
  1529.             
  1530. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1531. //  Local functions
  1532.  
  1533.                         
  1534.                                             
  1535. //////////////////////////////////////////////// END OF THIS FILE ////////////////////////////////////////////////////////////////
  1536.                                 
  1537.  
  1538.